package com.example.designpatterns.behavioral.visitor;

import java.util.ArrayList;
import java.util.List;

/**
 * 对象结构：商场商品集合
 *
 * @author scott
 */
public class MallProductCollection {

    private List<Product> products = new ArrayList<>();

    public void addProduct(Product product) {
        products.add(product);
    }

    public void removeProduct(Product product) {
        products.remove(product);
    }

    public void accept(Visitor visitor) {
        for (Product product : products) {
            product.accept(visitor);
        }
    }
}
